using System;
using dnAnalytics.Nli;

/// <summary>
/// Calculate norms
/// </summary>
internal class Program {
	[STAThread]
	private static void Main() {
		//use the MKL LAPACK provider
		ILapack lapack = Lapack.Provider(LapackProvider.Mkl);

		/*
		    1.1 2.2 3.3 4.4 5.5  
		a = 6.6 7.7 8.8 9.9 0.0
			9.8 7.6 5.4 3.2 1.0
		*/

		//row ordering
		double[] a = new double[] {1.1, 6.6, 9.8, 2.2, 7.7, 7.6, 3.3, 8.8, 5.4, 4.4, 9.9, 3.2, 5.5, 0, 1.0};

        //calculate 1-norm
        double norm = lapack.Dlange('1', 3, 5, a, 3);
		Console.WriteLine(norm + "\n");

        //calculate the infinity norm
        norm = lapack.Dlange('I', 3, 5, a, 3);
		Console.WriteLine(norm + "\n");

        //calculate the Frobenius norm
        norm = lapack.Dlange('F', 3, 5, a, 3);
		Console.WriteLine(norm + "\n");

		/* 
		Output:
		17.5

		33

		23.2174503337468		
		*/
	}
}